package com.tuanzi.loan.business.repository.sms;

import java.util.Date;
import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;

import com.tuanzi.loan.business.entity.sms.SmsSendTask;
import com.tuanzi.loan.business.entity.sms.SmsSendTaskStatus;
import com.tuanzi.loan.business.repository.sms.custom.SmsSendTaskRepositoryCustom;

public interface SmsSendTaskRepository extends SmsSendTaskRepositoryCustom, JpaRepository<SmsSendTask, Long> {

	SmsSendTask findTopByStatusAndExecuteTimeBefore(SmsSendTaskStatus status, Date executeDate);

	SmsSendTask findTopByStatus(SmsSendTaskStatus status);

	SmsSendTask findTopByCalculateTaskIdAndStatus(Long calculateTaskId, SmsSendTaskStatus status);
	
	Long countByStatus(SmsSendTaskStatus status);

	List<SmsSendTask> findAllByCalculateTaskId(Long calculateTaskId);
	
	List<SmsSendTask> findAllByStatusAndExecuteTimeAfter(SmsSendTaskStatus status, Date executeDate);

	List<SmsSendTask> findByStatusAndSendTimeIsNotNull(SmsSendTaskStatus status);
	
}
